package com.gdut.huayan.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.gdut.huayan.validation.NumRange;
import com.gdut.huayan.validation.group.GroupAdd;
import com.gdut.huayan.validation.group.GroupUpdate;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;


@Data
@EqualsAndHashCode(callSuper = false)
@TableName("t_stock")
@NoArgsConstructor
public class Stock implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Null(groups = {GroupAdd.class},message = "stockId需为空")
    @NotNull(groups = {GroupUpdate.class},message = "stockId不能为空")
    private Long id;

    /**
     * 节日id
     */
    //@NotNull(groups = {GroupAdd.class},message = "法会id不能为空")
    private Long festivalId;

    /**
     * 供奉点id
     */
    //@NotNull(groups = {GroupAdd.class},message = "法堂id不能为空")
    private Long locationId;

    /**
     * 活动id
     */
    @NotNull(groups = {GroupAdd.class},message = "活动id不能为空")
    private Long activityId;

    /**
     * 1-大，2-中，3-小
     */
    @NumRange(min = 1,max = 3)
    private Integer tabletSize;

    /**
     * 1-固定，2-价格级别，3-建议，4-自定义
     */
    @NumRange(min = 1,max = 4,message = "金额类型错误")
    private Integer moneyType;

    /**
     * 金额（分）
     */
    @NotNull(groups = {GroupAdd.class}, message = "金额数量不能为空")
    @Min(value = 0,message = "金额不能小于0")
    private Integer moneyAmount;

    /**
     * -1为无限额
     */
    @Min(value = -1,message = "可参与人数过小")
    private Integer amount;

    /**
     * 已售出
     */
    @Min(value = 0,message = "已参与人数不能为负数")
    private Integer sell;

    /**
     * 订单详情
     */
    private String remark;

    /**
     * 乐观锁版本号
     */
    @Version
    private Integer version;


    public Stock(String remark){
        this.remark = remark;
    }
}
